import Home from './view/home'
import './App.css'

import { useState, useEffect } from 'react'
import { useSelector, useDispatch } from 'react-redux'
import { getUserGuid, getListApi } from './store/moduls/user'

function App() {
  return (
    <>
      <div>
        <div>下面是我的孩子们</div>
        <Home></Home>
        <BComponent></BComponent>
      </div>
    </>
  )
}

function BComponent() {
  const Dispatch = useDispatch()
  const { guid, list } = useSelector(state => state.user)
  useEffect(() => {
    Dispatch(getListApi())
  }, [Dispatch])

  return (
    <>
      {list.map((i: { name: string; id: number }) => (
        <div key={i.id}>{i.name}</div>
      ))}
      <div
        onClick={() => {
          Dispatch(getUserGuid('6666'))
        }}
      >
        我是B组件:{guid}
      </div>
    </>
  )
}
export default App
